$('.tel').blur(function(){
	 var mobile=/^1[34578]\d{9}$/;            	
    if(mobile.test($(this).val())==false){ 
    
    	$(this).parents('.fu').next('i').html("手机号码有误，请重填")
		$(this).css("border-color","red");
		$(this).parents('.fu').css("border-color","red");
		$(this).parents('.fu').find('i').css("color","red");
        return false; 
    }else{
    	$(this).parents('.fu').next('i').html("")
		$(this).css("border-color","#dce1e6");
		$(this).parents('.fu').css("border-color","#dce1e6");
		$(this).parents('.fu').find('i').css("color","#dce1e6");
    }
})
$('.passward').blur(function(){
	
    if (this.value.length<6 || this.value.length > 12) {
        $(this).parents('.fu').next('i').html("请设置密码6-12位")
		$(this).css("border-color","red");
		$(this).parents('.fu').css("border-color","red");
		$(this).parents('.fu').find('i').css("color","red");
        
    }else{
    	$(this).parents('.fu').next('i').html("")
		$(this).css("border-color","#dce1e6");
		$(this).parents('.fu').css("border-color","#dce1e6");
		$(this).parents('.fu').find('i').css("color","#dce1e6");
    } 
	  
})
$('.loginbtn').click(function(event){
	if($('.tel').val()==""){
		$('.tel').parents('.fu').next('i').html("手机号不能为空")
		event.preventDefault();
	}
	if($('.passward').val()==""){
		$('.passward').parents('.fu').next('i').html("密码不能为空")
        event.preventDefault();
	}
	if($('.code').val()==""){
		$('.code').parents('.fu').next('i').html("验证码不能为空")
        event.preventDefault();
	}
	
})

//传参
var lacalurl= window.location.href;
var nn= /\/([^\/]*?)\/?$/.exec(new URL(lacalurl).pathname)[1];
ename=nn.substr(0, nn.length - 5)
if(ename ==undefined){
		
		

	}else{
		var nn=_ksbaonamelist;
		for(var i=0;i<_ksbaonamelist.length;i++){
			var name= _ksbaonamelist[i].name;
			var _ename=_ksbaonamelist[i].en;
			if(ename==_ename){
				$('.session label').html(name);
				$('.top label').html(name)
			}
	//	console.log(nn)
		}
	}	
 function getUrlParms() {
	
	
	var b = new Object();
	var f = location.search.substring(1);
	var e = f.split("&");
	for(var c = 0; c < e.length; c++) {
		var g = e[c].indexOf("=");
		if(g == -1) {
			continue
		}
		var a = e[c].substring(0, g);
		var d = e[c].substring(g + 1);
		b[a] = decodeURI(d)
	}
	return b
}

	
	var c = getUrlParms();
	var ename=c.ename
	if(ename ==undefined){
		
		$('.top label').html("牛课宝典在线做题")
		$('.ztop label').html("助考宝典在线做题")
	}else{
		var nn=_ksbaonamelist;
		for(var i=0;i<_ksbaonamelist.length;i++){
			var name= _ksbaonamelist[i].name;
			var _ename=_ksbaonamelist[i].en;
			if(ename==_ename){
				$('.session label').html(name)
				$('.top label').html(name)
			}
	//	console.log(nn)
		}
	} 


function getUrlParms() {
	
	
	var b = new Object();
	var f = location.search.substring(1);
	var e = f.split("&");
	
	for(var c = 0; c < e.length; c++) {
		var g = e[c].indexOf("=");
		
		if(g == -1) {
			continue
		}
		var a = e[c].substring(0, g);
		var d = e[c].substring(g + 1);
		b[a] = decodeURI(d)
		console.log(a)
		console.log(d)
	}
	return b
}

	
	var c = getUrlParms();
	var url = window.location.href
	var str = url.substr(-10)
	var ename=c.ename
	var nname = str.substr(0,5)
	
	var nn=_ksbaonamelist;
	for(var i=0;i<_ksbaonamelist.length;i++){
		var name= _ksbaonamelist[i].name;
		
		var _ename=_ksbaonamelist[i].en;
		
		if(ename==_ename){
			$('.registervalue').val(name)			
			$('.top label').html(name)
		}
		if(nname==_ename){
			
			$('.registervalue').val(name)			
			$('.top label').html(name)
			if(name=="牛课宝典公众号"||name=="牛课网公众号"||name=="牛课网.cn"){
			$('.top label').html("牛课宝典")
			}
		
		}
	}


//注册倒计时
var countdown=60;
function settime(obj) {
	 var mobile=/^1[34578]\d{9}$/;            	
    if(mobile.test($('.tel').val())==false){ 
    
    	$('.tel').parents('.fu').next('span').html("手机号码有误，请重填")
		$('.tel').css("border-color","red");
		$('.tel').parents('.fu').css("border-color","red");
		$('.tel').parents('.fu').find('i').css("color","red");
        return false; 
    }else{
    	if (countdown == 0) {
        obj.removeAttribute("disabled");   
        obj.value="免费获取验证码";
        countdown = 60;
        return;
	    } else {
	        obj.setAttribute("disabled", true);
	        obj.value="重新发送(" + countdown + ")";
	        countdown--;
	    }
	setTimeout(function() {
	    settime(obj) }
	    ,1000)
	}
    }
    


document.addEventListener('plusready', function() {
var webview = plus.webview.currentWebview();
plus.key.addEventListener('backbutton', function() {
webview.canBack(function(e) {
if(e.canBack) {
webview.back();
} else {
webview.close(); //hide,quit
//plus.runtime.quit();
}
})
});
});
